import cv2 as cv
import numpy as np


img = np.zeros((300,400), np.uint8)

step = 100
min,max = step,400
for s in range(min,max,step):
    print(s)
    img[:,0+s:min+s] = 40 + 200*s/max

threshold = 127
maxValue = 255
thresholdType = cv.THRESH_BINARY
ret, thresh = cv.threshold(img, threshold, maxValue, thresholdType)

cv.imshow('img', img)
cv.imshow('thresh', thresh)

cv.waitKey(0)
cv.destroyAllWindows()